package dao;

import domain.ContractModel;
import domain.ContractModelExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface ContractModelMapper {
    long countByExample(ContractModelExample example);

    int deleteByExample(ContractModelExample example);

    @Delete({
        "delete from contract_model",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into contract_model (Id, type_id, ",
        "model_code, name, ",
        "effective, enter_time, ",
        "location, from_source)",
        "values (#{id,jdbcType=INTEGER}, #{typeId,jdbcType=INTEGER}, ",
        "#{modelCode,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{effective,jdbcType=INTEGER}, #{enterTime,jdbcType=DATE}, ",
        "#{location,jdbcType=VARCHAR}, #{fromSource,jdbcType=VARCHAR})"
    })
    int insert(ContractModel record);

    int insertSelective(ContractModel record);

    List<ContractModel> selectByExample(ContractModelExample example);

    @Select({
        "select",
        "Id, type_id, model_code, name, effective, enter_time, location, from_source",
        "from contract_model",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("dao.ContractModelMapper.BaseResultMap")
    ContractModel selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") ContractModel record, @Param("example") ContractModelExample example);

    int updateByExample(@Param("record") ContractModel record, @Param("example") ContractModelExample example);

    int updateByPrimaryKeySelective(ContractModel record);

    @Update({
        "update contract_model",
        "set type_id = #{typeId,jdbcType=INTEGER},",
          "model_code = #{modelCode,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "effective = #{effective,jdbcType=INTEGER},",
          "enter_time = #{enterTime,jdbcType=DATE},",
          "location = #{location,jdbcType=VARCHAR},",
          "from_source = #{fromSource,jdbcType=VARCHAR}",
        "where Id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ContractModel record);
}